import Button from '../packages/Button/index.js'
import Dialog from '../packages/Dialog/index.js'
import Lazyload from '../packages/Lazyload'
import MessageBox from '../packages/MessageBox/index.js'
import Picker from '../packages/Picker/index.js'
import Search from '../packages/Search/index.js'
import Swipe from '../packages/Swipe/index.js'
import SwipeItem from '../packages/SwipeItem/index.js'
import Switch from '../packages/Switch/index.js'
import Toast from '../packages/Toast/index.js'
import Popup from '../packages/Popup/index.js'
import Radio from '../packages/Radio/index.js'
import RadioGroup from '../packages/RadioGroup/index.js'
import Checkbox from '../packages/Checkbox/index.js'
import CheckboxGroup from '../packages/CheckboxGroup/index.js'
import ImagePreview from '../packages/ImagePreview/index.js'
import Tooltip from '../packages/Tooltip/index.js'
import ActionSheet from '../packages/ActionSheet/index.js'
import ScrollerView from '../packages/ScrollerView/index.js'
import Header from '../packages/Header/index.js'
import Tabbar from '../packages/Tabbar/index.js'
import TabItem from '../packages/TabItem/index.js'
import TabContainer from '../packages/TabContainer/index.js'
import TabContainerItem from '../packages/TabContainerItem/index.js'
import Cell from '../packages/Cell/index.js'
import Badge from '../packages/Badge/index.js'
import Navbar from '../packages/Navbar/index.js'

import './assets/styles/reset.css'
import './assets/styles/theme-default/index.scss'
import './assets/styles/iconfont/iconfont.css'


// 组件列表
const components = [
  Button,
  Dialog,
  Search,
  Switch,
  Swipe,
  SwipeItem,
  Popup,
  Radio,
  RadioGroup,
  Checkbox,
  CheckboxGroup,
  Tooltip,
  ScrollerView,
  Header,
  Tabbar,
  TabItem,
  TabContainer,
  TabContainerItem,
  Cell,
  Badge,
  Navbar
]
const install = function(Vue) {
  // 判断是否安装
  if (install.installed) return
  // 遍历注册全局组件
  components.map(component => Vue.component(component.name, component))

  Vue.prototype.$Toast = Toast
  Vue.use(Lazyload, {try: 3})
  Vue.prototype.$ActionSheet = ActionSheet
  Vue.prototype.$ImagePreview = ImagePreview
  Vue.prototype.$MessageBox = MessageBox
  Vue.prototype.$Picker = Picker
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

const version = '0.1.8'

export default{
  install,
  version,
  Lazyload,
  ActionSheet,
  ImagePreview,
  MessageBox,
  Picker,
  Toast,
  ...components
}
